home *** CD-ROM | disk | FTP | other *** search
/ Windows Game Programming for Dummies (2nd Edition) / WinGamProgFD.iso / pc / DirectX SDK / DXSDK / samples / Multimedia / VBSamples / Misc / DXSetup / group.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  2001-10-08  |  7.9 KB  |  257 lines

  1. VERSION 5.00
  2. Begin VB.Form frmGroup 
  3.    BorderStyle     =   3  'Fixed Dialog
  4.    Caption         =   "* #"
  5.    ClientHeight    =   5250
  6.    ClientLeft      =   1095
  7.    ClientTop       =   1515
  8.    ClientWidth     =   5460
  9.    ClipControls    =   0   'False
  10.    HasDC           =   0   'False
  11.    Icon            =   "group.frx":0000
  12.    LockControls    =   -1  'True
  13.    MaxButton       =   0   'False
  14.    MinButton       =   0   'False
  15.    NegotiateMenus  =   0   'False
  16.    ScaleHeight     =   350
  17.    ScaleMode       =   3  'Pixel
  18.    ScaleWidth      =   364
  19.    ShowInTaskbar   =   0   'False
  20.    Begin VB.DirListBox dir95Groups 
  21.       Height          =   930
  22.       Left            =   765
  23.       TabIndex        =   8
  24.       Top             =   60
  25.       Visible         =   0   'False
  26.       Width           =   3810
  27.    End
  28.    Begin VB.Frame Frame1 
  29.       Height          =   30
  30.       Left            =   105
  31.       TabIndex        =   7
  32.       Top             =   4650
  33.       Width           =   5220
  34.    End
  35.    Begin VB.CommandButton cmdCancel 
  36.       Cancel          =   -1  'True
  37.       Caption         =   "#"
  38.       Height          =   345
  39.       Left            =   2880
  40.       MaskColor       =   &H00000000&
  41.       TabIndex        =   3
  42.       Top             =   4800
  43.       Width           =   1140
  44.    End
  45.    Begin VB.CommandButton cmdContinue 
  46.       Caption         =   "#"
  47.       Default         =   -1  'True
  48.       Height          =   345
  49.       Left            =   1395
  50.       MaskColor       =   &H00000000&
  51.       TabIndex        =   2
  52.       Top             =   4800
  53.       Width           =   1140
  54.    End
  55.    Begin VB.ListBox lstGroups 
  56.       Height          =   2010
  57.       ItemData        =   "group.frx":0442
  58.       Left            =   1080
  59.       List            =   "group.frx":0449
  60.       Sorted          =   -1  'True
  61.       TabIndex        =   1
  62.       Top             =   2220
  63.       Width           =   3240
  64.    End
  65.    Begin VB.TextBox txtGroup 
  66.       Height          =   300
  67.       Left            =   1080
  68.       MaxLength       =   128
  69.       TabIndex        =   0
  70.       Text            =   "*"
  71.       Top             =   1410
  72.       Width           =   3270
  73.    End
  74.    Begin VB.Label lblDDE 
  75.       Height          =   225
  76.       Left            =   225
  77.       TabIndex        =   9
  78.       Top             =   1350
  79.       Visible         =   0   'False
  80.       Width           =   705
  81.    End
  82.    Begin VB.Label lblGroups 
  83.       AutoSize        =   -1  'True
  84.       Caption         =   "#"
  85.       Height          =   195
  86.       Left            =   1080
  87.       TabIndex        =   6
  88.       Top             =   1950
  89.       Width           =   105
  90.    End
  91.    Begin VB.Label lblGroup 
  92.       AutoSize        =   -1  'True
  93.       Caption         =   "#"
  94.       Height          =   195
  95.       Left            =   1080
  96.       TabIndex        =   5
  97.       Top             =   1170
  98.       Width           =   105
  99.    End
  100.    Begin VB.Label lblMain 
  101.       AutoSize        =   -1  'True
  102.       Caption         =   "#"
  103.       Height          =   195
  104.       Left            =   180
  105.       TabIndex        =   4
  106.       Top             =   165
  107.       Width           =   5100
  108.       WordWrap        =   -1  'True
  109.    End
  110. Attribute VB_Name = "frmGroup"
  111. Attribute VB_GlobalNameSpace = False
  112. Attribute VB_Creatable = False
  113. Attribute VB_PredeclaredId = True
  114. Attribute VB_Exposed = False
  115. Option Explicit
  116. Private mstrGroup As String
  117. Private mstrDefGroup As String
  118. Private mstrProgramsPath As String
  119. Private mfrm As Form
  120. Private mfPrivate As Boolean
  121. Private mfStartMenu As Boolean
  122. Private Sub cmdCancel_Click()
  123.     ExitSetup frmGroup, gintRET_EXIT
  124. End Sub
  125. Private Sub cmdContinue_Click()
  126.     mstrGroup = txtGroup.Text
  127.     If Not fCreateProgGroup() Then
  128.         '
  129.         ' Couldn't create the group. Let
  130.         ' the user try again.
  131.         '
  132.         txtGroup.SetFocus
  133.     Else
  134.         '
  135.         ' The group got created ok, so unload Choose Program Group dialog
  136.         ' and continue on with setup.
  137.         '
  138.         Unload Me
  139.     End If
  140. End Sub
  141. Private Function fCreateProgGroup() As Boolean
  142. ' Create a program group.
  143.     Dim strMsg As String
  144.     If Not fValidFilename(mstrGroup) Then
  145.         strMsg = ResolveResString(resGROUPINVALIDGROUPNAME, gstrPIPE1, CStr(gintMAX_PATH_LEN), gstrPIPE2, ResolveResString(resCOMMON_INVALIDFILECHARS))
  146.         MsgFunc strMsg, vbOKOnly Or vbQuestion, gstrTitle
  147.         Exit Function
  148.     End If
  149.     '
  150.     'Go ahead and create the main program group
  151.     '
  152.     If Not fCreateShellGroup(mstrGroup, True, , mfPrivate, mfStartMenu) Then
  153.         Exit Function
  154.     End If
  155.     fCreateProgGroup = True
  156. End Function
  157. Private Sub Form_Load()
  158.     '
  159.     ' Initialize localized control properties.
  160.     '
  161.     SetFormFont Me
  162.     Caption = ResolveResString(resGROUPFRM, gstrPIPE1, gstrAppName)
  163.     lblMain.Caption = ResolveResString(resGROUPLBLMAIN)
  164.     lblGroup.Caption = ResolveResString(resGROUPLBLGROUP)
  165.     lblGroups.Caption = ResolveResString(resGROUPLBLGROUPS)
  166.     cmdContinue.Caption = ResolveResString(resGROUPBTNCONTINUE)
  167.     cmdCancel.Caption = ResolveResString(resLOG_vbCancel)
  168.     '
  169.     ' Initialize the Program Group text box with the
  170.     ' title of the application.
  171.     '
  172.     txtGroup.Text = gstrTitle
  173.     '
  174.     ' Load the ListBox with the program manager groups.
  175.     '
  176.     LoadW95Groups
  177.     '
  178.     ' Initialize the Program Group textbox with the
  179.     ' default group selected in the list box.
  180.     '
  181.     lstGroups_Click
  182. End Sub
  183. Private Sub lstGroups_Click()
  184.     txtGroup.Text = lstGroups.Text
  185. End Sub
  186. Private Sub txtGroup_Change()
  187.     cmdContinue.Enabled = Len(Trim$(txtGroup.Text)) > 0
  188. End Sub
  189. Private Sub LoadW95Groups()
  190. ' This routine uses the system registry to
  191. ' retrieve a list of all the subfolders in the
  192. ' \windows\start menu\programs folder.
  193.     Dim strFolder As String
  194.     Dim iFolder As Integer
  195.     mstrProgramsPath = strGetProgramsFilesPath()
  196.     strFolder = Dir$(mstrProgramsPath, vbDirectory)   ' Retrieve the first entry.
  197.     lstGroups.Clear
  198.     Do While Len(strFolder) > 0
  199.         '
  200.         ' Ignore the current directory and the encompassing directory.
  201.         '
  202.         If strFolder <> "." Then
  203.             If strFolder <> ".." Then
  204.                 '
  205.                 ' Verify that we actually got a directory and not a file.
  206.                 '
  207.                 If DirExists(mstrProgramsPath & strFolder) Then
  208.                     '
  209.                     ' We got a directory, add it to the list.
  210.                     '
  211.                     lstGroups.AddItem strFolder
  212.                 End If
  213.             End If
  214.         End If
  215.         '
  216.         ' Get the next subfolder in the Programs folder
  217.         '
  218.         strFolder = Dir$
  219.     Loop
  220.     '
  221.     ' The lstGroups listbox now contains a listing of all the Programs
  222.     ' subfolders (the groups).
  223.     '
  224.     ' Look for the default folder in the list and select it.  If it's
  225.     ' not there, add it.
  226.     '
  227.     iFolder = SendMessageString(lstGroups.hWnd, LB_FINDSTRINGEXACT, -1, mstrDefGroup)
  228.     If iFolder = LB_ERR Then
  229.         '
  230.         ' The group doesn't yet exist, add it to the list.
  231.         '
  232.         lstGroups.AddItem mstrDefGroup
  233.         lstGroups.ListIndex = lstGroups.NewIndex
  234.     Else
  235.         lstGroups.ListIndex = iFolder
  236.     End If
  237. End Sub
  238. Public Property Get GroupName(frm As Form, strDefGroup As String, Optional fPriv As Boolean = True, Optional ByVal fStart As Boolean = False) As String
  239.     mstrDefGroup = strDefGroup
  240.     Set mfrm = frm
  241.     mfPrivate = fPriv
  242.     mfStartMenu = fStart
  243.     If gfNoUserInput Then
  244.         mstrGroup = mstrDefGroup
  245.         If Not fCreateProgGroup() Then
  246.             ExitSetup frmSetup1, gintRET_FATAL
  247.         End If
  248.     Else
  249.         Show vbModal
  250.     End If
  251.     GroupName = mstrGroup
  252. End Property
  253. Private Sub txtGroup_GotFocus()
  254.     txtGroup.SelStart = 0
  255.     txtGroup.SelLength = Len(txtGroup.Text)
  256. End Sub
  257.